{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1647090780.2049236\n",
      "time.struct_time(tm_year=2022, tm_mon=3, tm_mday=12, tm_hour=21, tm_min=13, tm_sec=0, tm_wday=5, tm_yday=71, tm_isdst=0)\n",
      "2022-03-12-March-Saturday 21:13:00\n"
     ]
    }
   ],
   "source": [
    "# time\n",
    "import time\n",
    "# 从1970年到当前时间经过的秒数\n",
    "print(time.time())\n",
    "\n",
    "print(time.localtime())\n",
    "# 格式化\n",
    "print(time.strftime('%Y-%m-%d-%B-%A %H:%M:%S'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2022-03-09 22:56:42.094551\n",
      "2022-03-19 22:56:42.094551\n",
      "<class 'datetime.datetime'> 2022-03-04 00:00:00\n"
     ]
    }
   ],
   "source": [
    "# datetime\n",
    "import datetime\n",
    "# 当前时间\n",
    "now = datetime.datetime.now()\n",
    "print(now)\n",
    "\n",
    "# 时间计算 timedelta()\n",
    "# 10天后的日期\n",
    "now_after = now + datetime.timedelta(days=10) \n",
    "print(now_after)\n",
    "\n",
    "# 将字符串格式化成 datetime\n",
    "time_str = datetime.datetime(2022,3,4)\n",
    "print(type(time_str) , time_str)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "     March 2022\n",
      "Mo Tu We Th Fr Sa Su\n",
      "    1  2  3  4  5  6\n",
      " 7  8  9 10 11 12 13\n",
      "14 15 16 17 18 19 20\n",
      "21 22 23 24 25 26 27\n",
      "28 29 30 31\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import calendar\n",
    "\n",
    "print(calendar.month(2022,3))\n"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "ff79ebfcf6806606a412477be2872c3ec52671763ecb054ca3010c66083164a3"
  },
  "kernelspec": {
   "display_name": "Python 3.8.3 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
